﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EvidenceManagement.Model.Entity;
using System.Runtime.Serialization;

namespace EvidenceManagement.Model.Security
{
    [DataContract]
    [DbObject(SelectCommandText = "SystemUser_Select"
        , InsertCommandText = "SystemUser_Insert"
        , DeleteCommandText = "SystemUser_Delete"
        , UpdateCommandText = "SystemUser_Update")]
    public class SystemUser : ISystemUser, IAuditable
    {
        public SystemUser()
        {
            Employee = new Employee();
        }

        #region ISystemUser Members
        
        [DbColumn][DataMember]
        public Guid SystemUserID { get; set; }

        [DbColumn][DataMember]
        public string UserName { get; set; }

        [DbColumn][DataMember]
        public string Password { get; set; }

        #endregion

        [DbRelation]
        public Employee Employee { get; set; }

        [DbColumn][DataMember]
        public Guid EmployeeID
        {
            get
            {
                return Employee.EmployeeID;
            }
            set
            {
                Employee.EmployeeID = value;
            }
        }

        [DbColumn][DataMember]
        public DateTime LastPasswordChangeDate { get; set; }

        [DbColumn][DataMember]
        public DateTime LastLoginDate { get; set; }

        [DbColumn][DataMember]
        public Guid ApprovedBy { get; set; }

        [DbColumn][DataMember]
        public DateTime ApprovedDate { get; set; }

        [DbColumn][DataMember]
        public bool IsApproved { get; set; }

        [DbColumn][DataMember]
        public bool IsLoggedOn { get; set; }

        [DbColumn][DataMember]
        public bool IsLockedOut { get; set; }

        #region IAuditable Members

        [DbColumn][DataMember]
        public Guid CreatedBy
        {
            get;
            set;
        }

        [DbColumn][DataMember]
        public Guid ModifiedBy
        {
            get;
            set;
        }

        public bool IsDeleted
        {
            get;
            set;
        }

        #endregion        
    }
}
